"""
闭包
    1.可以让一个变量常驻于内存
    2.避免全局变量被修改
"""
def func():
    a = 10

    # 闭包
    def inner():
        nonlocal a
        a+=1
        print(a)
        return a

    return inner

ret = func()

ret()
ret()
ret()
ret()
b = ret()
print(b)
